﻿#pragma once
#ifdef _VC
//忽略应用到函数类型的const限定符警告
#pragma warning(disable:4180)
#endif
namespace LK
{
	//辅助模板类

	/**@brief 成员V表示模板参数b*/
	template<bool b>struct TypeBoolean
	{
		static const bool V = b;
		operator const bool()const { return b; }
	};
	/**@brief 成员type表示模板参数的sizie_t值*/
	template<const size_t t>struct TypeEnum { static const size_t type = t; };
	/**@brief 成员T表示模版参数类型t*/
	template<class t>struct TypeDefine { typedef t T; };
	/**@brief 成员表示类型限定符代号*/
	struct TypeExtents
	{
		/**@brief 常量*/
		static const size_t Const = 0x1;
		/**@brief 直接写入内存*/
		static const size_t Volatile = 0x2;
		/**@brief 左值引用*/
		static const size_t LValueReference = 0x4;
		/**@brief 右值引用*/
		static const size_t RValueReference = 0x8;
		/**@brief 指针*/
		static const size_t Pointer = 0x10;
		/**@brief 数组*/
		static const size_t Array = 0x20;
		/**@brief 函数调用方式和类型*/
		static const size_t Cdecl = 0x100;
		/**@brief 函数调用方式和类型*/
		static const size_t Stdcall = 0x200;
		/**@brief 函数调用方式和类型*/
		static const size_t Fastcall = 0x400;
		/**@brief 函数调用方式和类型：托管函数*/
		static const size_t Clrcall = 0x800;
		/**@brief 函数调用方式和类型：成员函数*/
		static const size_t Thiscall = 0x1000;
		/**@brief 函数调用方式和类型：成员函数const*/
		static const size_t ThiscallConst = 0x2000;
		/**@brief 函数调用方式和类型：可变参*/
		static const size_t Variable = 0x4000;
	};
	/**@brief 当模版参数包内所有元素都一样时，成员V为true*/
	template<class T>struct ArgIsSame;
	/**@brief 当模版参数包内有参数跟T一样时，成员V为true*/
	template<class T, class ArgPack>struct ArgHasT;
	/**@brief 成员T表示两个参数包的参数连接所得参数包*/
	template<class ArgPack1, class ArgPack2>struct ArgCombine;
	/**@brief 成员T表示从参数包中移除索引为index的1个参数所得参数包*/
	template<const size_t index, class ArgPack>struct ArgRemoveAt;
	/**@brief 成员T表示从参数包中索引为index的参数起移除n个参数所得参数包*/
	template<const size_t index, const size_t n, class ArgPack>struct ArgRemove;
	/**@brief 成员T表示参数包中索引为index的参数，参数从0数起*/
	template<size_t const index, class T>struct ArgT;
#ifdef SUPPORT_VARIADIC_TEMPLATES
	/**@brief 参数包，用以打包可变参数，成员ArgCount指示参数数量*/
	template<class ...Args>struct VarArgsPack { static const size_t ArgCount = sizeof...(Args); };
	/**@brief 在参数包VarArgsPack中的参数都一样时，成员V为true，否则为false*/
	template<class T0, class T1, class ...Args>struct ArgIsSame<VarArgsPack<T0, T1, Args...> > :TypeBoolean<ArgIsSame<VarArgsPack<T1, Args...> >::V&&ArgIsSame<VarArgsPack<T0, T1> >::V >{};
	template<class T0, class T1>struct ArgIsSame<VarArgsPack<T0, T1> > :TypeBoolean<false>{};
	template<class T>struct ArgIsSame<VarArgsPack<T, T> > :TypeBoolean<true>{};
	/**@brief 在模板参数都一样时，静态成员V为true，否则为false*/
	template<class...Args>struct IsSame :TypeBoolean<ArgIsSame<VarArgsPack<Args...> >::V > {};
	/**@brief 当模版参数包内有参数跟T一样时，成员V为true，成员index表示第一个出现的位置，从0开始*/
	template<class T, class T1, class ...Args>struct ArgHasT<T, VarArgsPack<T1, Args...> > :TypeBoolean<IsSame<T, T1>::V || ArgHasT<T, VarArgsPack<Args...> >::V >{ static const index_t index = IsSame<T, T1>::V ? 0 : ArgHasT<T, VarArgsPack<Args...> >::index == -1 ? -1 : ArgHasT<T, VarArgsPack<Args...> >::index + 1; };
	template<class T>struct ArgHasT<T, VarArgsPack<> > :TypeBoolean<false>{ static const index_t index = -1; };
	/**@brief 当有其它参数和T一样时，成员V为true*/
	template<class T, class ...Args>struct HasT :ArgHasT<T, VarArgsPack<Args...> > {};
	/**@brief 成员T表示两个参数包的参数连接所得参数包*/
	template<class ...Args1, class ...Args2>struct ArgCombine<VarArgsPack<Args1...>, VarArgsPack<Args2...> > { typedef VarArgsPack<Args1..., Args2...>  T; };
	/**@brief 成员T表示从参数包中index个参数移除1个参数所得参数包*/
	template<const size_t index, class T0, class ...Args>struct ArgRemoveAt<index, VarArgsPack<T0, Args...> > :ArgCombine<VarArgsPack<T0>, typename ArgRemoveAt<index - 1, VarArgsPack<Args...> >::T>{};
	template<class T0, class ...Args>struct ArgRemoveAt<0, VarArgsPack<T0, Args...> > { typedef VarArgsPack<Args...>  T; };
	template<>struct ArgRemoveAt<-1, VarArgsPack<> > { typedef VarArgsPack<> T; };
	/**@brief 成员T表示从参数包中index起参数移除n个参数所得参数包*/
	template<const size_t index, const size_t n, class ...Args>struct ArgRemove<index, n, VarArgsPack<Args...> > :ArgRemoveAt<index, typename ArgRemove<index + 1, n - 1, VarArgsPack<Args...> >::T>{};
	template<const size_t index, class ...Args>struct ArgRemove<index, 0, VarArgsPack<Args...> > { typedef VarArgsPack<Args...> T; };
	/**@brief 成员T为VarArgsPack中的第index个元素*/
	template<size_t const index, class T0, class ...Args>struct ArgT<index, VarArgsPack<T0, Args...> > { typedef typename ArgT < index - 1, VarArgsPack<Args...> >::T T; };
	template<class T0, class ...Args>struct ArgT<0, VarArgsPack<T0, Args...>> { typedef T0 T; };
	template<>struct ArgT<0, VarArgsPack<>> { typedef null_t T; };
	/**@brief 成员T为第index个模板参数；比如当index为0时，成员T将表示T0*/
	template<size_t const index, class ...Args>struct UseT { typedef typename ArgT < index, VarArgsPack<Args...> >::T T; };
#else
	//参数包，用以打包可变参数，成员ArgCount指示参数数量，使用null_t表示未使用的空位，最多33个参数
	template<MF4_RepeatAsc_(class T, =null_t, 0, _MRP_CNTM0) >struct VarArgsPack { static const size_t ArgCount = _MRP_CNTM0+1; };
#define TMPF(x)\
	template<MF4_RepeatAsc_(class T,,0,x) >struct VarArgsPack<MF4_RepeatAsc_(T,,0,x)>{ static const size_t ArgCount = x+1; };
	MF3_RepeatAsc(TMPF, 0, _MRP_CNTM1)
#undef TMPF
		template<>struct VarArgsPack<> { static const size_t ArgCount = 0; };
	//参数包加长版
	template<MF4_RepeatAsc_(class LT, =null_t, 0, _MRP_CNTM0), MF4_RepeatAsc_(class RT, =null_t, 0, _MRP_CNTM0)>
	struct LongVarArgsPack { typedef VarArgsPack<MF4_RepeatAsc_(LT, , 0, _MRP_CNTM0)> T; };
	//成员T为截取第一个参数包Pack1的前index个参数放置到二个参数包Pack2前部所形成参数包
	template<const size_t index, class Pack1, class Pack2>struct ArgPack1Insert2;
	template<MF4_RepeatAsc_(class LT, , 0, _MRP_CNTM0), MF4_RepeatAsc_(class RT, , 0, _MRP_CNTM0)>
	struct ArgPack1Insert2<0, VarArgsPack<MF4_RepeatAsc_(LT, , 0, _MRP_CNTM0)>, VarArgsPack<MF4_RepeatAsc_(RT, , 0, _MRP_CNTM0)> >
	{
		typedef typename LongVarArgsPack<MF4_RepeatAsc_(RT, , 0, _MRP_CNTM0)>::T  T;
	};
#define TMPF(x)\
	template<MF4_RepeatAsc_(class LT,,0,_MRP_CNTM0),MF4_RepeatAsc_(class RT,,0,_MRP_CNTM0)>\
	struct ArgPack1Insert2<x+1, VarArgsPack<MF4_RepeatAsc_(LT,,0,_MRP_CNTM0)>, VarArgsPack<MF4_RepeatAsc_(RT,,0,_MRP_CNTM0)> >\
		 { typedef typename LongVarArgsPack<MF4_RepeatAsc_(LT,,0,x),MF4_RepeatAsc_(RT,,0,_MRP_CNTM0)>::T  T; };
	MF3_RepeatAsc(TMPF, 0, _MRP_CNTM1);
#undef TMPF
	//在VarArgsPack包有成员一样时，静态成员V为true，否则为false
	template<MF4_RepeatAsc_(class T, , 0, _MRP_CNTM0)>struct ArgIsSame<VarArgsPack<MF4_RepeatAsc_(T, , 0, _MRP_CNTM0)> > :TypeBoolean<ArgIsSame<VarArgsPack<MF4_RepeatAsc_(T, , 1, _MRP_CNTM0)> >::V&&ArgIsSame<VarArgsPack<T0, T1> >::V >{};
	template<class T0, class T1>struct ArgIsSame<VarArgsPack<T0, T1> > :TypeBoolean<false>{};
	template<class T>struct ArgIsSame<VarArgsPack<T, T> > :TypeBoolean<true>{};
	//在有成员一样时，静态成员V为true，否则为false
	template<MF4_RepeatAsc_(class T, =null_t, 0, _MRP_CNTM0)>struct IsSame :ArgIsSame<VarArgsPack<MF4_RepeatAsc_(T, , 0, _MRP_CNTM0)> > {};
	//当模版参数包内有参数跟T一样时，成员V为true
	template<class T, MF4_RepeatAsc_(class T, , 0, _MRP_CNTM0)>struct ArgHasT<T, VarArgsPack<MF4_RepeatAsc_(T, , 0, _MRP_CNTM0)> > :TypeBoolean<IsSame<T, T0>::V || ArgHasT<T, VarArgsPack<MF4_RepeatAsc_(T, , 1, _MRP_CNTM0)> >::V >{
	static const index_t index = IsSame<T, T0>::V ? 0 : ArgHasT<T, VarArgsPack<MF4_RepeatAsc_(T,,1, _MRP_CNTM0)> >::index == -1 ? -1 : ArgHasT<T, VarArgsPack<MF4_RepeatAsc_(T,,1, _MRP_CNTM0)> >::index + 1; };
	template<class T>struct ArgHasT<T, VarArgsPack<> > :TypeBoolean<false>{ static const index_t index = -1; };
	//当有其它参数和T一样时，成员V为true
	template<class T, MF4_RepeatAsc_(class T, =null_t, 0, _MRP_CNTM0)>struct HasT
		:ArgHasT<T, VarArgsPack<MF4_RepeatAsc_(T, , 0, _MRP_CNTM0)> > {};

	//成员T为VarArgsPack中索引为index的元素
	template<size_t const index, MF4_RepeatAsc_(class T, , 0, _MRP_CNTM0) >struct ArgT<index, VarArgsPack<MF4_RepeatAsc_(T, , 0, _MRP_CNTM0)> > :ArgT<index - 1, VarArgsPack<MF4_RepeatAsc_(T, , 1, _MRP_CNTM0)> >{};
	template<MF4_RepeatAsc_(class T, , 0, _MRP_CNTM0) >struct ArgT<0, VarArgsPack<MF4_RepeatAsc_(T, , 0, _MRP_CNTM0) > > { typedef T0 T; };
	template<>struct ArgT<0, VarArgsPack<> > { typedef TypeDefine<void > T; };

	//成员T表示两个参数包的参数连接所得参数包
	template<class ArgPack1, class ArgPack2>struct ArgCombine { typedef typename ArgPack1Insert2<ArgPack1::ArgCount, ArgPack1, ArgPack2>::T T; };
	//成员T表示从参数包中移除索引为index的1个参数所得参数包
	template<const size_t index, MF4_RepeatAsc_(class T, , 0, _MRP_CNTM0)>struct ArgRemoveAt<index, VarArgsPack<MF4_RepeatAsc_(T, , 0, _MRP_CNTM0)> > :ArgCombine<VarArgsPack<T0>, typename ArgRemoveAt<index - 1, VarArgsPack<MF4_RepeatAsc_(T, , 1, _MRP_CNTM0)> >::T>{};
	template<MF4_RepeatAsc_(class T, , 0, _MRP_CNTM0)>struct ArgRemoveAt<0, VarArgsPack<MF4_RepeatAsc_(T, , 0, _MRP_CNTM0)> > { typedef VarArgsPack<MF4_RepeatAsc_(T, , 1, _MRP_CNTM0)> T; };
	template<>struct ArgRemoveAt<-1, VarArgsPack<> > { typedef VarArgsPack<> T; };
	//成员T表示从参数包中索引为index的参数起移除n个参数所得参数包
	template<const size_t index, const size_t n, MF4_RepeatAsc_(class T, , 0, _MRP_CNTM0)>struct ArgRemove<index, n, VarArgsPack<MF4_RepeatAsc_(T, , 0, _MRP_CNTM0)> > :ArgRemoveAt<index, typename ArgRemove<index + 1, n - 1, VarArgsPack<MF4_RepeatAsc_(T, , 0, _MRP_CNTM0)> >::T>{};
	template<const size_t index, MF4_RepeatAsc_(class T, , 0, _MRP_CNTM0)>struct ArgRemove<index, 0, VarArgsPack<MF4_RepeatAsc_(T, , 0, _MRP_CNTM0)> > { typedef VarArgsPack< MF4_RepeatAsc_(T, , 0, _MRP_CNTM0)> T; };
	//成员T表示索引为index的类型，index为0时指示第一个类型
	template<size_t const index, MF4_RepeatAsc_(class T, =null_t, 0, _MRP_CNTM0)>struct UseT :ArgT<index, VarArgsPack<MF4_RepeatAsc_(T, , 0, _MRP_CNTM0)> > {};
#endif

	/**@brief 当T为托管句柄类型时，静态成员V为true，否则为false*/
	template<class TT >struct IsGCHandle :TypeBoolean<false> { typedef TT T; };
	/**@brief 当T为托管类型时，静态成员为true，否则为false*/
	template<class TT >struct IsGCType:TypeBoolean<IsGCHandle<TT>::V >{};
	template<class TT >struct IsGCType<TT const> :IsGCType<TT> {};
	template<class TT >struct IsGCType<TT volatile> :IsGCType<TT> {};
	template<class TT >struct IsGCType<TT volatile const> :IsGCType<TT> {};
	template<class TT >struct IsGCType<TT &> :IsGCType<TT> {};
	template<class TT >struct IsGCType<TT const&> :IsGCType<TT> {};
	template<class TT >struct IsGCType<TT volatile&> :IsGCType<TT> {};
	template<class TT >struct IsGCType<TT volatile const&> :IsGCType<TT> {};
	template<class TT, size_t s >struct IsGCType<TT[s]> :IsGCType<TT> {};
	template<class TT >struct IsGCType<TT*> :IsGCType<TT> {};
	/**@brief 当参数中含有托管句柄类型时，静态成员V为true，否则为false*/
	template<class T>struct ArgHasGCHandle :TypeBoolean<false> {};
#ifdef SUPPORT_VARIADIC_TEMPLATES
	template<class T, class ...Args>struct ArgHasGCHandle<VarArgsPack<T, Args...> > :TypeBoolean<IsGCHandle<T>::V || ArgHasGCHandle<VarArgsPack<Args...> >::V>{};
	template<class ...Args>struct HasGCHandle :ArgHasGCHandle<VarArgsPack<Args...> > {};
#else
	//当参数中含有托管句柄类型时，静态成员V为true，否则为false
	template<MF4_RepeatAsc_(class T, , 0, _MRP_CNTM0) >struct ArgHasGCHandle<VarArgsPack<MF4_RepeatAsc_(T, , 0, _MRP_CNTM0)> > :TypeBoolean<IsGCHandle<T0>::V || ArgHasGCHandle<VarArgsPack<MF4_RepeatAsc_(T, , 1, _MRP_CNTM0)> >::V>{};
	template<class T0, class T1 >struct ArgHasGCHandle<VarArgsPack<T0, T1> > :TypeBoolean<IsGCHandle<T0>::V || IsGCHandle<T1>::V>{};
	template<MF4_RepeatAsc_(class T, =null_t, 0, _MRP_CNTM0) >struct HasGCHandle :ArgHasGCHandle<VarArgsPack<MF4_RepeatAsc_(T, , 0, _MRP_CNTM0)> > {};
#endif
#ifdef _CLR
	template<class TT >struct IsGCHandle<TT^> :TypeBoolean<true>{ typedef gcroot<TT^> T; };
	template<class TT >struct IsGCHandle<TT^const> :TypeBoolean<true>{ typedef gcroot<TT^const> T; };
	template<class TT >struct IsGCHandle<TT^const volatile> :TypeBoolean<true>{ typedef gcroot<TT^const volatile> T; };
	template<class TT >struct IsGCHandle<TT^volatile> :TypeBoolean<true>{ typedef gcroot<TT^volatile> T; };
	template<class TT >struct IsGCHandle<TT^%> :TypeBoolean<true>{ typedef gcroot<TT^> T; };
	template<class TT >struct IsGCHandle<TT^const%> :TypeBoolean<true>{ typedef gcroot<TT^const> T; };
	template<class TT >struct IsGCHandle<TT^const volatile%> :TypeBoolean<true>{ typedef gcroot<TT^const volatile> T; };
	template<class TT >struct IsGCHandle<TT^volatile%> :TypeBoolean<true>{ typedef gcroot<TT^ volatile> T; };
	//数组偏特化
	template<class TT, index_t v>struct IsGCHandle<array<TT, v>^> :TypeBoolean<true> { typedef gcroot<array<TT, v>^> T; };
	template<class TT, index_t v>struct IsGCHandle<array<TT, v>^const> :TypeBoolean<true> { typedef gcroot<array<TT, v>^ const> T; };
	template<class TT, index_t v>struct IsGCHandle<array<TT, v>^volatile> :TypeBoolean<true> { typedef gcroot<array<TT, v>^ volatile> T; };
	template<class TT, index_t v>struct IsGCHandle<array<TT, v>^const volatile> :TypeBoolean<true> { typedef gcroot<array<TT, v>^const volatile> T; };
	template<class TT, index_t v>struct IsGCHandle<array<TT, v>^volatile%> :TypeBoolean<true> { typedef gcroot<array<TT, v>^ volatile> T; };
	template<class TT, index_t v>struct IsGCHandle<array<TT, v>^const%> :TypeBoolean<true> { typedef gcroot<array<TT, v>^ const> T; };
	template<class TT, index_t v>struct IsGCHandle<array<TT, v>^%> :TypeBoolean<true> { typedef gcroot<array<TT, v>^> T; };
	template<class TT, index_t v>struct IsGCHandle<array<TT, v>^const volatile%> :TypeBoolean<true> { typedef gcroot<array<TT, v>^const volatile> T; };
#endif
	/**@brief 当T是void或const void时，静态成员V为true，否则为false*/
	template<class T>struct IsVoid { static const bool V = IsSame<T, void>::V || IsSame<T, const void>::V; };

	/**@brief 当T是数组(非引用、无限定)时，静态成员V为true，否则为false*/
	template<class T>struct IsArray :TypeBoolean < false >, null_t { static size_t const C = 0; };
	template<class T, size_t c>struct IsArray<T[c]> :TypeBoolean<true>, TypeDefine<T>{ static size_t const C = c; };

	/**@brief 当T为左值引用时，静态成员V为true，否则为false*/
	template<class T>struct IsLValueReference :TypeBoolean<false> {};
	template<class T>struct IsLValueReference<T&> :TypeBoolean<true>{};
	template<class T>struct IsLValueReference<T const&> :TypeBoolean<true>{};
	template<class T>struct IsLValueReference<T volatile&> :TypeBoolean<true>{};
	template<class T>struct IsLValueReference<T volatile const&> :TypeBoolean<true>{};
#ifdef _CLR
	template<class T >struct IsLValueReference<T^%> :TypeBoolean<true>{};
	template<class T >struct IsLValueReference<T^const%> :TypeBoolean<true>{};
	template<class T >struct IsLValueReference<T^const volatile%> :TypeBoolean<true>{};
	template<class T >struct IsLValueReference<T^volatile%> :TypeBoolean<true>{};
#endif

	/**@brief 当T为右值引用时，静态成员V为true，否则为false*/
	template<class T>struct IsRValueReference :TypeBoolean<false> {};
#ifdef _USE_RIGHT_VALUE_REFERENCE
	template<class T>struct IsRValueReference<T &&> :TypeBoolean<true>{};
	template<class T>struct IsRValueReference<T const&&> :TypeBoolean<true>{};
	template<class T>struct IsRValueReference<T volatile&&> :TypeBoolean<true>{};
	template<class T>struct IsRValueReference<T volatile const&&> :TypeBoolean<true>{};
#endif

	/**@brief 当T为左值引用或右值引用时，静态成员V为true，否则为false*/
	template<class T>struct IsReference :TypeBoolean<IsRValueReference <T>::V || IsLValueReference<T>::V> {};

	/**
	@brief 当T为常量（比如char const& 等）时，静态成员V为true，否则为false
	@note T为数组类型时，成员V为false*/
	template<class T>struct IsConst :TypeBoolean<false> {};
	template<class T>struct IsConst<T const> :TypeBoolean<true>{};
	template<class T>struct IsConst<T const&> :TypeBoolean<true>{};
	template<class T>struct IsConst<T volatile const> :TypeBoolean<true>{};
	template<class T>struct IsConst<T volatile const&> :TypeBoolean<true>{};
#ifdef _USE_RIGHT_VALUE_REFERENCE
	template<class T>struct IsConst<T const&&> :TypeBoolean<true>{};
	template<class T>struct IsConst<T volatile const&&> :TypeBoolean<true>{};
#endif
	/**
	@brief 当T为volatile（比如 char volatile &、char volatile const）时，静态成员V为true，否则为false
	@note T为数组类型时，成员V为false*/
	template<class T>struct IsVolatile :TypeBoolean<false> {};
	template<class T>struct IsVolatile<T volatile> :TypeBoolean<true>{};
	template<class T>struct IsVolatile<T volatile&> :TypeBoolean<true>{};
	template<class T>struct IsVolatile<T volatile const> :TypeBoolean<true>{};
	template<class T>struct IsVolatile<T volatile const&> :TypeBoolean<true>{};
#ifdef _USE_RIGHT_VALUE_REFERENCE
	template<class T>struct IsVolatile<T volatile&&> :TypeBoolean<true>{};
	template<class T>struct IsVolatile<T volatile const&&> :TypeBoolean<true>{};
#endif

	/**@brief 获取指针层级*/
	template<class LT>struct PointerLevel { typedef LT T; static const size_t V = 0; };
	template<class LT, const size_t c>struct PointerLevel<LT[c]> { typedef LT T[c]; static const size_t V = 0; };
	template<class T>struct PointerLevel<T *> :PointerLevel < T >{ static const size_t V = PointerLevel<T>::V + 1; };
	template<class T>struct PointerLevel<T const> :PointerLevel<T>{};
	template<class T>struct PointerLevel<T volatile> :PointerLevel<T>{};
	template<class T>struct PointerLevel<T volatile const> :PointerLevel<T>{};
	template<class T>struct PointerLevel<T &> :PointerLevel<T>{};
	template<class T>struct PointerLevel<T const&> :PointerLevel<T>{};
	template<class T>struct PointerLevel<T volatile &> :PointerLevel<T>{};
	template<class T>struct PointerLevel<T volatile const&> :PointerLevel<T>{};
#ifdef _USE_RIGHT_VALUE_REFERENCE
	template<class T>struct PointerLevel<T &&> :PointerLevel<T>{};
	template<class T>struct PointerLevel<T const&&> :PointerLevel<T>{};
	template<class T>struct PointerLevel<T volatile&&> :PointerLevel<T>{};
	template<class T>struct PointerLevel<T volatile const&&> :PointerLevel<T>{};
#endif
	/**@brief 当T为指针（比如 char*&、int const*）时，静态成员V为true，否则为false*/
	template<class T>struct IsPointer :TypeBoolean<PointerLevel<T>::V != 0> {};


	/**@brief 当模版参数T为右值引用（比如char const&&、int volatile &&）时，成员T表示模版参数LT所引用的类型*/
	template<class LT>struct RemoveRValueReference { typedef LT T; };
#ifdef _USE_RIGHT_VALUE_REFERENCE
	template<class LT>struct RemoveRValueReference<LT &&> { typedef LT T; };
	template<class LT>struct RemoveRValueReference<LT const&&> { typedef LT const T; };
	template<class LT>struct RemoveRValueReference<LT volatile&&> { typedef LT volatile T; };
	template<class LT>struct RemoveRValueReference<LT volatile const&&> { typedef LT volatile const T; };
#endif

	/**@brief 当模版参数T为左值引用时，成员T表示模版参数LT所引用的类型*/
	template<class LT>struct RemoveLValueReference { typedef LT T; };
	template<class LT>struct RemoveLValueReference<LT&> { typedef LT T; };
	template<class LT>struct RemoveLValueReference<LT const&> { typedef LT const T; };
	template<class LT>struct RemoveLValueReference<LT volatile&> { typedef LT volatile T; };
	template<class LT>struct RemoveLValueReference<LT volatile const&> { typedef LT volatile const T; };
#ifdef _CLR
	template<class LT >struct RemoveLValueReference<LT^%> { typedef LT^ T; };
	template<class LT >struct RemoveLValueReference<LT^const%> { typedef LT^ const T; };
	template<class LT >struct RemoveLValueReference<LT^const volatile%> { typedef LT^ volatile const T; };
	template<class LT >struct RemoveLValueReference<LT^volatile%> { typedef LT^ volatile T; };
#endif

	/**@brief 成员T表示模版参数LT所引用的类型*/
	template<class LT>struct RemoveReference { typedef typename RemoveLValueReference<typename RemoveRValueReference<LT>::T>::T T; };

	/**@brief 成员LT表示模版参数LT对应的非常量类型*/
	template<class LT>struct RemoveConst { typedef LT  T; };
	template<class LT>struct RemoveConst<LT const> { typedef LT  T; };
	template<class LT>struct RemoveConst<LT const&> { typedef LT&  T; };
	template<class LT>struct RemoveConst<LT volatile const> { typedef LT volatile  T; };
	template<class LT>struct RemoveConst<LT volatile const&> { typedef LT volatile&  T; };
#ifdef _CLR
	template<class LT>struct RemoveConst<LT^ const> { typedef LT^ T; };
	template<class LT>struct RemoveConst<LT^ const%> { typedef LT^% T; };
	template<class LT>struct RemoveConst<LT^ volatile const> { typedef LT^ volatile  T; };
	template<class LT>struct RemoveConst<LT^ volatile const%> { typedef LT^ volatile% T; };
#endif
#ifdef _USE_RIGHT_VALUE_REFERENCE
	template<class LT>struct RemoveConst<LT const&&> { typedef LT && T; };
	template<class LT>struct RemoveConst<LT volatile const&&> { typedef LT volatile&& T; };
#endif

	/**@brief 成员LT表示模版参数LT对应的非volatile类型*/
	template<class LT>struct RemoveVolatile { typedef LT T; };
	template<class LT>struct RemoveVolatile<LT volatile> { typedef LT T; };
	template<class LT>struct RemoveVolatile<LT volatile&> { typedef LT& T; };
	template<class LT>struct RemoveVolatile<LT volatile const> { typedef LT const T; };
	template<class LT>struct RemoveVolatile<LT volatile const&> { typedef LT const& T; };
#ifdef _CLR
	template<class LT>struct RemoveVolatile<LT^ volatile> { typedef LT^ T; };
	template<class LT>struct RemoveVolatile<LT^ volatile%> { typedef LT% T; };
	template<class LT>struct RemoveVolatile<LT^ volatile const> { typedef LT^ const T; };
	template<class LT>struct RemoveVolatile<LT^ volatile const%> { typedef LT^ const% T; };
#endif
#ifdef _USE_RIGHT_VALUE_REFERENCE
	template<class LT>struct RemoveVolatile<LT volatile&&> { typedef LT && T; };
	template<class LT>struct RemoveVolatile<LT volatile const&&> { typedef LT const&& T; };
#endif

	/**@brief 成员V表示T类型的外层TypeExtents码*/
	template<class T>struct GetExtents
	{
		static const size_t V = IsConst<T>::V*TypeExtents::Const
			+ IsVolatile<T>::V*TypeExtents::Volatile
			+ IsLValueReference<T>::V*TypeExtents::LValueReference
			+ IsRValueReference<T>::V*TypeExtents::RValueReference
			+ IsPointer<T>::V*TypeExtents::Pointer
			+ IsArray<T>::V*TypeExtents::Array;
	};
	/**@brief 成员T表示移除所有对类型LT的限定得到的类型*/
	template<class LT>struct RemoveAllExtents { typedef LT T; };
	template<class LT>struct RemoveAllExtents<LT const> { typedef LT T; };
	template<class LT>struct RemoveAllExtents<LT volatile> { typedef LT T; };
	template<class LT>struct RemoveAllExtents<LT volatile const> { typedef LT T; };
	template<class LT>struct RemoveAllExtents<LT&> { typedef LT T; };
	template<class LT>struct RemoveAllExtents<LT const&> { typedef LT T; };
	template<class LT>struct RemoveAllExtents<LT volatile&> { typedef LT T; };
	template<class LT>struct RemoveAllExtents<LT volatile const&> { typedef LT T; };
#ifdef _USE_RIGHT_VALUE_REFERENCE
	template<class LT>struct RemoveAllExtents<LT&&> { typedef LT T; };
	template<class LT>struct RemoveAllExtents<LT const&&> { typedef LT T; };
	template<class LT>struct RemoveAllExtents<LT volatile&&> { typedef LT T; };
	template<class LT>struct RemoveAllExtents<LT volatile const&&> { typedef LT T; };
#endif
	/**@brief 当模板参数LT为指针时，成员T表示模版参数LT指向的类型，比如当模板参数LT为const int**&时，成员LT为const int**/
	template<class LT>struct RemovePointer { typedef LT T; };
	template<class LT>struct RemovePointer<LT*> { typedef LT T; };
	template<class LT>struct RemovePointer<LT* const> { typedef LT T; };
	template<class LT>struct RemovePointer<LT* volatile> { typedef LT T; };
	template<class LT>struct RemovePointer<LT* volatile const> { typedef LT T; };
	template<class LT>struct RemovePointer<LT*&> { typedef LT T; };
	template<class LT>struct RemovePointer<LT* const&> { typedef LT T; };
	template<class LT>struct RemovePointer<LT* volatile&> { typedef LT T; };
	template<class LT>struct RemovePointer<LT* volatile const&> { typedef LT T; };
#ifdef _USE_RIGHT_VALUE_REFERENCE
	template<class LT>struct RemovePointer<LT*&&> { typedef LT T; };
	template<class LT>struct RemovePointer<LT* const&&> { typedef LT T; };
	template<class LT>struct RemovePointer<LT* volatile&&> { typedef LT T; };
	template<class LT>struct RemovePointer<LT* volatile const&&> { typedef LT T; };
#endif

#ifdef _CLR
	template<class LT>struct RemoveAllExtents<LT^> { typedef LT^ T; };
	template<class LT>struct RemoveAllExtents<LT^ const> { typedef LT^ T; };
	template<class LT>struct RemoveAllExtents<LT^ volatile> { typedef LT^ T; };
	template<class LT>struct RemoveAllExtents<LT^ volatile const> { typedef LT^ T; };
	template<class LT>struct RemoveAllExtents<LT^%> { typedef LT^ T; };
	template<class LT>struct RemoveAllExtents<LT^ const%> { typedef LT^ T; };
	template<class LT>struct RemoveAllExtents<LT^ volatile%> { typedef LT^ T; };
	template<class LT>struct RemoveAllExtents<LT^ volatile const%> { typedef LT^ T; };
#endif




	/**@brief 成员T表示模版参数LT对应的左值引用类型*/
	template<class LT>struct AddLValueReference { typedef LT& T; };
	template<class LT>struct AddLValueReference<LT&> { typedef LT& T; };
	template<class LT>struct AddLValueReference<LT volatile&> { typedef LT volatile& T; };
	template<class LT>struct AddLValueReference<LT const&> { typedef LT const& T; };
	template<class LT>struct AddLValueReference<LT const> { typedef LT const& T; };
	template<class LT>struct AddLValueReference<LT volatile> { typedef LT volatile& T; };
	template<class LT>struct AddLValueReference<LT volatile const> { typedef LT const volatile& T; };
	template<class LT>struct AddLValueReference<LT volatile const&> { typedef LT const volatile& T; };
	template<>struct AddLValueReference<void> { typedef void T; };
	template<>struct AddLValueReference<const void> { typedef const void T; };
#ifdef _CLR
	template<class LT>struct AddLValueReference<LT^ > { typedef LT^% T; };
	template<class LT>struct AddLValueReference<LT^%> { typedef LT^% T; };
	template<class LT>struct AddLValueReference<LT^ const> { typedef LT^ const% T; };
	template<class LT>struct AddLValueReference<LT^ const%> { typedef LT^ const% T; };
	template<class LT>struct AddLValueReference<LT^ volatile> { typedef LT^ volatile% T; };
	template<class LT>struct AddLValueReference<LT^ volatile%> { typedef LT^ volatile% T; };
	template<class LT>struct AddLValueReference<LT^ volatile const> { typedef LT^ volatile const% T; };
	template<class LT>struct AddLValueReference<LT^ volatile const%> { typedef LT^ volatile const% T; };
#endif
#ifdef _USE_RIGHT_VALUE_REFERENCE
	template<class LT>struct AddLValueReference<LT &&> { typedef LT& T; };
	template<class LT>struct AddLValueReference<LT const&&> { typedef LT const& T; };
	template<class LT>struct AddLValueReference<LT volatile&&> { typedef LT volatile& T; };
	template<class LT>struct AddLValueReference<LT volatile const&&> { typedef LT volatile const& T; };
#endif

	/**@brief 成员T表示模版参数LT对应的常量类型*/
	template<class LT>struct AddConst { typedef LT const T; };
	template<class LT>struct AddConst<LT const> { typedef LT const T; };
	template<class LT>struct AddConst<LT &> { typedef LT const& T; };
	template<class LT>struct AddConst<LT const&> { typedef LT const& T; };
	template<class LT>struct AddConst<LT volatile> { typedef LT volatile const T; };
	template<class LT>struct AddConst<LT volatile&> { typedef LT const volatile& T; };
	template<class LT>struct AddConst<LT volatile const> { typedef LT volatile const T; };
	template<class LT>struct AddConst<LT volatile const&> { typedef LT const volatile& T; };
#ifdef _CLR
	template<class LT>struct AddConst<LT^ > { typedef LT^const T; };
	template<class LT>struct AddConst<LT^%> { typedef LT^const% T; };
	template<class LT>struct AddConst<LT^ const> { typedef LT^ const T; };
	template<class LT>struct AddConst<LT^ const%> { typedef LT^ const% T; };
	template<class LT>struct AddConst<LT^ volatile> { typedef LT^ volatile const T; };
	template<class LT>struct AddConst<LT^ volatile%> { typedef LT^ volatile const% T; };
	template<class LT>struct AddConst<LT^ volatile const> { typedef LT^ volatile const T; };
	template<class LT>struct AddConst<LT^ volatile const%> { typedef LT^ volatile const% T; };
	template<class LT,int d>struct AddConst<array<LT,d>^ &> { typedef array<LT, d>^ & T; };
#endif
#ifdef _USE_RIGHT_VALUE_REFERENCE
	template<class LT>struct AddConst<LT &&> { typedef LT const&& T; };
	template<class LT>struct AddConst<LT const&&> { typedef LT const&& T; };
	template<class LT>struct AddConst<LT volatile&&> { typedef LT volatile const&& T; };
	template<class LT>struct AddConst<LT volatile const&&> { typedef LT volatile const&& T; };
#endif

	/**@brief 成员T表示模版参数LT对应的volatile类型*/
	template<class LT>struct AddVolatile { typedef LT volatile T; };
	template<class LT>struct AddVolatile<LT volatile> { typedef LT volatile T; };
	template<class LT>struct AddVolatile<LT &> { typedef LT volatile& T; };
	template<class LT>struct AddVolatile<LT const&> { typedef LT const volatile& T; };
	template<class LT>struct AddVolatile<LT const> { typedef LT volatile const T; };
	template<class LT>struct AddVolatile<LT volatile&> { typedef LT volatile& T; };
	template<class LT>struct AddVolatile<LT volatile const> { typedef LT volatile const T; };
	template<class LT>struct AddVolatile<LT volatile const&> { typedef LT const volatile& T; };
#ifdef _CLR
	template<class LT>struct AddVolatile<LT^ > { typedef LT^volatile T; };
	template<class LT>struct AddVolatile<LT^%> { typedef LT^volatile% T; };
	template<class LT>struct AddVolatile<LT^ const> { typedef LT^ const volatile T; };
	template<class LT>struct AddVolatile<LT^ const%> { typedef LT^ const volatile% T; };
	template<class LT>struct AddVolatile<LT^ volatile> { typedef LT^ volatile T; };
	template<class LT>struct AddVolatile<LT^ volatile%> { typedef LT^ volatile% T; };
	template<class LT>struct AddVolatile<LT^ volatile const> { typedef LT^ volatile const T; };
	template<class LT>struct AddVolatile<LT^ volatile const%> { typedef LT^ volatile const% T; };
#endif
	/**
	@brief 成员T表示模版参数LT对应的指针类型
	@note 成员T将移除引用限定*/
	template<class LT>struct AddPointer { typedef LT * T; };
	template<class LT>struct AddPointer<LT volatile> { typedef LT volatile* T; };
	template<class LT>struct AddPointer<LT &> { typedef LT * T; };
	template<class LT>struct AddPointer<LT const&> { typedef LT const* T; };
	template<class LT>struct AddPointer<LT const> { typedef LT const* T; };
	template<class LT>struct AddPointer<LT volatile&> { typedef LT volatile* T; };
	template<class LT>struct AddPointer<LT volatile const> { typedef LT volatile const* T; };
	template<class LT>struct AddPointer<LT volatile const&> { typedef LT const volatile* T; };
#ifdef _CLR
	template<class LT>struct AddPointer<LT^ > { typedef LT^* T; };
	template<class LT>struct AddPointer<LT^%> { typedef LT^* T; };
	template<class LT>struct AddPointer<LT^ const> { typedef LT^ const* T; };
	template<class LT>struct AddPointer<LT^ const%> { typedef LT^ const * T; };
	template<class LT>struct AddPointer<LT^ volatile> { typedef LT^ volatile* T; };
	template<class LT>struct AddPointer<LT^ volatile%> { typedef LT^ volatile* T; };
	template<class LT>struct AddPointer<LT^ volatile const> { typedef LT^ volatile const* T; };
	template<class LT>struct AddPointer<LT^ volatile const%> { typedef LT^ volatile const* T; };
#endif
#ifdef _USE_RIGHT_VALUE_REFERENCE
	template<class LT>struct AddVolatile<LT &&> { typedef LT volatile&& T; };
	template<class LT>struct AddVolatile<LT const&&> { typedef LT volatile const&& T; };
	template<class LT>struct AddVolatile<LT volatile&&> { typedef LT volatile&& T; };
	template<class LT>struct AddVolatile<LT volatile const&&> { typedef LT volatile const&& T; };
#endif

#ifdef _USE_RIGHT_VALUE_REFERENCE
	/**@brief 成员T为模版参数LT对应的右值引用类型*/
	template<class LT>struct AddRValueReference { typedef LT&& T; };
	template<class LT>struct AddRValueReference<LT volatile> { typedef LT volatile&& T; };
	template<class LT>struct AddRValueReference<LT &> { typedef LT && T; };
	template<class LT>struct AddRValueReference<LT const&> { typedef LT const&& T; };
	template<class LT>struct AddRValueReference<LT const> { typedef LT const&& T; };
	template<class LT>struct AddRValueReference<LT volatile&> { typedef LT volatile&& T; };
	template<class LT>struct AddRValueReference<LT volatile const> { typedef LT volatile const&& T; };
	template<class LT>struct AddRValueReference<LT volatile const&> { typedef LT volatile const&& T; };
	template<class LT>struct AddRValueReference<LT &&> { typedef LT&& T; };
	template<class LT>struct AddRValueReference<LT const&&> { typedef LT const&& T; };
	template<class LT>struct AddRValueReference<LT volatile&&> { typedef LT volatile&& T; };
	template<class LT>struct AddRValueReference<LT volatile const&&> { typedef LT volatile const&& T; };
#endif
	template<class U>static inline long ___IsConvertibleTest(U p) { return 0; }
	template<class U>static inline unsigned char ___IsConvertibleTest(...) { return 0; }

	/**@brief 当From可以隐式转换为To时，静态成员V为true，否则为false*/
	template<class From, class To>struct IsConvertible
	{
	private:
		typedef typename RemoveAllExtents<From>::T F;
		typedef typename RemoveAllExtents<To>::T T;
	public:
		static const bool V = (IsSame<T, F>::V && (
			IsReference<To>::V >= IsReference<From>::V&&IsConst<To>::V >= IsConst<From>::V&&IsVolatile<To>::V >= IsVolatile<From>::V
			)) || sizeof(___IsConvertibleTest<To>(*(typename AddPointer<F>::T)0)) == sizeof(long);
	};


	template<class U>inline long ___IsClassOrUnionTest(void(U::* p)()) { return 0; }
	template<class U>inline char ___IsClassOrUnionTest(...) { return 0; }
	template<class U>inline long ___IsBaseOfTest(U* p) { return 0; }
	template<class U>inline char ___IsBaseOfTest(...) { return 0; }

	/**@brief 当Base是Derived的基类时，静态成员V为true，否则为false*/
	template<class Base, class Derived>struct IsBaseOf
	{
	private:
		typedef typename RemoveVolatile<typename RemoveConst<typename RemoveReference<Base>::T>::T>::T B;
		typedef typename RemoveVolatile<typename RemoveConst<typename RemoveReference<Derived>::T>::T>::T D;
	public:
		static const bool V = sizeof(___IsBaseOfTest<B>((D*)0)) == sizeof(long)&&!IsVoid<Base>::V;
	};

	/**@brief 当T为类、共用体或结构体时，成员V为true，否则为false*/
	template<class T>struct IsClassOrUnion :TypeBoolean<sizeof(___IsClassOrUnionTest<T>(0)) == sizeof(long)> {};

	/**@brief 当T是浮点型数据（通过传入0.5判断）时，静态成员V为true，否则为false*/
	template<class T>struct IsFloat
	{
	private:
		typedef typename UseT<IsConvertible<double, T>::V, int, T>::T Type;
	public:
		static const bool V = Type(0.5) > Type(0.0);
	};

	/**@brief 当T是整型数据（通过传入1判断）时，静态成员V为true，否则为false*/
	template<class T>struct IsIntegral
	{
		typedef typename RemoveAllExtents<T>::T TT;
	public:
		static const bool V = IsSame<TT, int>::V || IsSame<TT, unsigned int>::V || IsSame<TT, unsigned long>::V || IsSame<TT, long>::V || IsSame<TT, long long>::V || IsSame<TT, unsigned long long>::V || IsSame<TT, short>::V || IsSame<TT, signed short>::V || IsSame<TT, char>::V || IsSame<TT, signed char>::V || IsSame<TT, unsigned char>::V || IsSame<TT, wchar_t>::V;
	};

	/**@brief 当T类型为纯虚类时，成员V为true，否则为false*/
	template<class T>struct IsAbstract
	{
	private:
		template<class U>static inline long test(U(*)[1]) { return 0; }
		template<class U>static inline char test(...) { return 0; }
	public:
		static const bool V = IsClassOrUnion<T>::V&&sizeof(test<T>(0)) == sizeof(char);
	};

	/**
	@brief 当T为函数类型（非函数指针、引用、const、volatile）时，成员V为true，否则为false，静态成员type是一个表示函数类型的整形值，成员T为对应函数的参数包类型
	@note 该模板与其它模板不同，不能对指针、const限定进行判断，判断前请自行RemoveAllExtents移除*/
	template<class T>struct IsFunction :TypeDefine<VarArgsPack<> >, TypeBoolean<false>, TypeEnum<0> {};
#ifdef SUPPORT_VARIADIC_TEMPLATES
	template<class R, class T, class ...Args>struct IsFunction<R(T::*)(Args...)> :TypeBoolean<true>, TypeDefine<VarArgsPack<R, T, Args...> >, TypeEnum<TypeExtents::Thiscall>{};
	template<class R, class T, class ...Args>struct IsFunction<R(T::*)(Args..., ...)> :TypeBoolean<true>, TypeDefine<VarArgsPack<R, T, Args...> >, TypeEnum<TypeExtents::Thiscall + TypeExtents::Variable>{};
	template<class R, class T, class ...Args>struct IsFunction<R(T::*)(Args...)const> :TypeBoolean<true>, TypeDefine<VarArgsPack<R, T, Args...> >, TypeEnum<TypeExtents::ThiscallConst>{};
	template<class R, class T, class ...Args>struct IsFunction<R(T::*)(Args..., ...)const> :TypeBoolean<true>, TypeDefine<VarArgsPack<R, T, Args...> >, TypeEnum<TypeExtents::ThiscallConst + TypeExtents::Variable>{};
	template<class R, class ...Args>struct IsFunction<R(Args...)> :TypeBoolean<true>, TypeDefine<VarArgsPack<R, void, Args...> >, TypeEnum<TypeExtents::Cdecl>{};
	template<class R, class ...Args>struct IsFunction<R(Args..., ...)> :TypeBoolean<true>, TypeDefine<VarArgsPack<R, void, Args...> >, TypeEnum<TypeExtents::Cdecl + TypeExtents::Variable>{};
#ifdef CANUSESTDCALL
	template<class R, class ...Args>struct IsFunction<R STDCALL(Args...)> :TypeBoolean<true>, TypeDefine<VarArgsPack<R, void, Args...> >, TypeEnum<TypeExtents::Stdcall>{};
#endif
#ifdef CANUSEFASTCALL
	template<class R, class ...Args>struct IsFunction<R FASTCALL(Args...)> :TypeBoolean<true>, TypeDefine<VarArgsPack<R, void, Args...> >, TypeEnum<TypeExtents::Fastcall>{};
#endif
#ifdef _CLR
	template<class R, class ...Args>struct IsFunction<R CLRCALL(Args...)> :TypeBoolean<true>, TypeDefine<VarArgsPack<R, void, Args...> >, TypeEnum<TypeExtents::Clrcall>{};
	template<class R, class T, class ...Args>struct IsFunction<R(CLRCALL T::*)(Args...)> :TypeBoolean<true>, TypeDefine<VarArgsPack<R, T, Args...> >, TypeEnum<TypeExtents::Clrcall + TypeExtents::Thiscall>{};
	template<class R, class T, class ...Args>struct IsFunction<R(CLRCALL T::*)(Args...)const> :TypeBoolean<true>, TypeDefine<VarArgsPack<R, T, Args...> >, TypeEnum<TypeExtents::Clrcall + TypeExtents::ThiscallConst>{};
#endif
#else//最多只能判断_MRP_CNTM1个参数，因为参数包最多容纳33个参数，而前两个参数分别表示返回值和thiscall对象类型

	//thiscall
#define TMPF(x)\
	template<MF4_RepeatAsc_(class T,,0,x) >struct IsFunction<T0(T1::*)(MF4_RepeatAsc_(T,,2,x))>\
		:TypeBoolean<true>, TypeDefine<VarArgsPack<MF4_RepeatAsc_(T,,0,x)> >, TypeEnum<TypeExtents::Thiscall>{};
MF3_RepeatAsc(TMPF, 1, _MRP_CNTM0)
#undef TMPF
//thiscall const
#define TMPF(x)\
	template<MF4_RepeatAsc_(class T,,0,x) >struct IsFunction<T0(T1::*)(MF4_RepeatAsc_(T,,2,x))const>\
		:TypeBoolean<true>, TypeDefine<VarArgsPack<MF4_RepeatAsc_(T,,0,x)> >, TypeEnum<TypeExtents::ThiscallConst>{};
MF3_RepeatAsc(TMPF, 1, _MRP_CNTM0)
#undef TMPF
//thiscall 可变参
#define TMPF1(x) T##x,
#define TMPF(x)\
	template<MF4_RepeatAsc_(class T,,0,x) >struct IsFunction<T0(T1::*)(MF3_RepeatAsc(TMPF1,2,x) ...)>\
		:TypeBoolean<true>, TypeDefine<VarArgsPack<MF4_RepeatAsc_(T,,0,x)> >, TypeEnum<TypeExtents::Thiscall + TypeExtents::Variable>{};
MF2_Repeatb(TMPF, _MRP_CNTM0)//这里再次使用MF3_RepeatAsc宏将导致展开终止，因此需改用MF2_Repeatb或者MF3_RepeatDec宏
#undef TMPF
		//thiscall const可变参
#define TMPF(x)\
	template<MF4_RepeatAsc_(class T,,0,x) >struct IsFunction<T0(T1::*)(MF3_RepeatAsc(TMPF1,2,x) ...)const>\
		:TypeBoolean<true>, TypeDefine<VarArgsPack<MF4_RepeatAsc_(T,,0,x)> >, TypeEnum<TypeExtents::ThiscallConst + TypeExtents::Variable>{};
	MF2_Repeatb(TMPF, _MRP_CNTM0)//这里再次使用MF3_RepeatAsc宏将导致展开终止，因此需改用MF2_Repeatb或者MF3_RepeatDec宏
#undef TMPF
#define TMPF_1(x) ,T##x
#define TMPC_1(x) ,class T##x
		//cdecl
#define TMPF(x)\
	template<class R MF3_RepeatAsc(TMPC_1,2,x) >struct IsFunction<R(MF4_RepeatAsc_(T,,2,x))>\
		:TypeBoolean<true>, TypeDefine<VarArgsPack<R ,void MF3_RepeatAsc(TMPF_1,2,x)> >, TypeEnum<TypeExtents::Cdecl>{};
	MF2_Repeatb(TMPF, _MRP_CNTM1)//这里再次使用MF3_RepeatAsc宏将导致展开终止，因此需改用MF2_Repeatb或者MF3_RepeatDec宏
#undef TMPF
		//cdecl 可变参
#define TMPF(x)\
	template<class R MF3_RepeatAsc(TMPC_1,2,x) >struct IsFunction<R(MF3_RepeatAsc(TMPF1,2,x)...)>\
		:TypeBoolean<true>, TypeDefine<VarArgsPack<R ,void MF3_RepeatAsc(TMPF_1,2,x)> >, TypeEnum<TypeExtents::Cdecl + TypeExtents::Variable>{};
	MF2_Repeatb(TMPF, _MRP_CNTM1)//这里再次使用MF3_RepeatAsc宏将导致展开终止，因此需改用MF2_Repeatb或者MF3_RepeatDec宏
#undef TMPF
#ifdef CANUSESTDCALL
		//stdcall
#define TMPF(x)\
	template<class R MF3_RepeatAsc(TMPC_1,2,x) >struct IsFunction<R STDCALL(MF4_RepeatAsc_(T,,2,x))>\
		:TypeBoolean<true>, TypeDefine<VarArgsPack<R ,void MF3_RepeatAsc(TMPF_1,2,x)> >, TypeEnum<TypeExtents::Stdcall>{};
	MF2_Repeatb(TMPF, _MRP_CNTM1)//这里再次使用MF3_RepeatAsc宏将导致展开终止，因此需改用MF2_Repeatb或者MF3_RepeatDec宏
#undef TMPF
#endif
#ifdef CANUSEFASTCALL
		 //fastcall
#define TMPF(x)\
	template<class R MF3_RepeatAsc(TMPC_1,2,x) >struct IsFunction<R FASTCALL(MF4_RepeatAsc_(T,,2,x))>\
		:TypeBoolean<true>, TypeDefine<VarArgsPack<R ,void MF3_RepeatAsc(TMPF_1,2,x)> >, TypeEnum<TypeExtents::Fastcall>{};
	MF2_Repeatb(TMPF, _MRP_CNTM1)//这里再次使用MF3_RepeatAsc宏将导致展开终止，因此需改用MF2_Repeatb或者MF3_RepeatDec宏
#undef TMPF
#endif
#ifdef _CLR
													  //clrcall
#define TMPF(x)\
	template<class R MF3_RepeatAsc(TMPC_1,2,x) >struct IsFunction<R CLRCALL(MF4_RepeatAsc_(T,,2,x))>\
		:TypeBoolean<true>, TypeDefine<VarArgsPack<R ,void MF3_RepeatAsc(TMPF_1,2,x)> >, TypeEnum<TypeExtents::Clrcall>{};
	MF2_Repeatb(TMPF, _MRP_CNTM1)
#undef TMPF
	//clrthiscall
#define TMPF(x)\
	template<MF4_RepeatAsc_(class T,,0,x) >struct IsFunction<T0 CLRCALL(T1::*)(MF4_RepeatAsc_(T,,2,x))>\
		:TypeBoolean<true>, TypeDefine<VarArgsPack<MF4_RepeatAsc_(T,,0,x)> >, TypeEnum<TypeExtents::Clrcall+ TypeExtents::Thiscall>{};
	MF3_RepeatAsc(TMPF, 1, _MRP_CNTM0)
#undef TMPF
	//clrthiscall const
#define TMPF(x)\
	template<MF4_RepeatAsc_(class T,,0,x) >struct IsFunction<T0 CLRCALL(T1::*)(MF4_RepeatAsc_(T,,2,x))const>\
		:TypeBoolean<true>, TypeDefine<VarArgsPack<MF4_RepeatAsc_(T,,0,x)> >, TypeEnum<TypeExtents::Clrcall + TypeExtents::ThiscallConst>{};
	MF3_RepeatAsc(TMPF, 1, _MRP_CNTM0)
#undef TMPF
#endif
#undef TMPF1
#undef TMPF_1
#undef TMPC_1
#endif

	/**
	@brief 成员operator()用以执行Check()->Func()调用*/
	template<class FunType, FunType fun>struct fref;
    /**@brief 当enable为true时，成员T表示模板参数T；当enable为false时，成员T不存在*/
    template<bool enable, class LT = void>struct UseIf { typedef LT T; };
	template<class T>struct UseIf<false, T> {};
	/**
	@brief 成员V表示类型参数T的特性(注：当T为Function时，其Const特性表示其是否是ThisCallConst)*/
	template<class T>struct ExtentsOf{
		static const size_t V =
			((!::LK::IsFunction<T>::V&&IsConst<T>::V) || bool(::LK::IsFunction<T>::type&::LK::TypeExtents::ThiscallConst))*::LK::TypeExtents::Const
			| IsVolatile<T>::V*TypeExtents::Volatile
			| IsLValueReference<T>::V*TypeExtents::LValueReference
			| IsRValueReference<T>::V*TypeExtents::RValueReference;
	};
	/**
	@brief 成员Method表示判断相等的方法*/
	template<class Left, class Right>struct EqualMethodObject
	{
		/**
		@breif T表示Method函数指针类型*/
		typedef bool(*T)(Left, Right);
		/**
		@breif l跟r相等时返回true，否则返回false*/
		static inline bool Method(Left l, Right r) { return l == r; }
	};
	/**
	@brief 成员Method表示判断大小的方法*/
	template<class Left, class Right>struct CompareMethodObject
	{
		/**
		@breif T表示Method函数指针类型*/
		typedef index_t(*T)(Left, Right);
		/**
		@breif l>r时返回1，l<r时返回-1，否则返回0*/
		static inline index_t Method(Left l, Right r) { return l > r ? 1 : l < r ? -1 : 0; }
	};

}
